spb/cancerindex
Public
TypeScript 97.2%
SQL 1.5%
CSS 0.6%
JavaScript 0.5%
1import { ogImage, OG_SIZE, OG_CONTENT_TYPE } from '@/lib/og';2import { getCancerBySlug, getCounters } from '@/lib/queries/cancers';3import { fmtInt, humanize } from '@/lib/format';45export const alt = 'CancerIndex cancer profile';6export const size = OG_SIZE;7export const contentType = OG_CONTENT_TYPE;8export const revalidate = 3600;910/** Share image of a cancer page: name, entity type, NCIt code and the deterministic counters (never estimates). */11export default async function Image({ params }: { params: Promise<{ slug: string }> }) {12 const { slug } = await params;13 const c = await getCancerBySlug(slug);14 if (!c) return ogImage({ kicker: 'Cancer', title: 'Entity not found', subtitle: slug });15 const k = await getCounters(c.id);16 const facts = [17 k?.active_trial_count ? { label: 'active trials', value: fmtInt(k.active_trial_count) } : null,18 k?.approved_drug_count ? { label: 'approved drugs', value: fmtInt(k.approved_drug_count) } : null,19 k?.evidence_count ? { label: 'evidence items', value: fmtInt(k.evidence_count) } : null,20 k?.publication_count_5y ? { label: 'publications · 5 y', value: fmtInt(k.publication_count_5y) } : null,21 ].filter((f): f is { label: string; value: string } => !!f);22 return ogImage({23 kicker: `${humanize(c.entity_type)}${c.primary_ncit_code ? ` · NCIt ${c.primary_ncit_code}` : ''}`,24 title: c.canonical_name,25 subtitle: c.description ?? (c.short_name && c.short_name !== c.canonical_name ? c.short_name : `Taxonomy, statistics, genomics, evidence, drugs, trials and rankings for ${c.canonical_name}.`),26 facts,27 sourcesNote: facts.length ? 'ClinicalTrials.gov · openFDA / Health Canada / EMA · CIViC · PubMed' : null,28 });29}30